package com.bydq.patrolsystem.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bydq.patrolsystem.entity.PsLogs;
import com.bydq.patrolsystem.service.PsLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/log")
@Controller
public class LogController {

    @Autowired
    private PsLogsService psLogsService;

    @GetMapping("/logList/{userCode}")
    public String logList(@PathVariable String userCode , Model model){
        model.addAttribute("userCode",userCode);
        return "logList";
    }

    @PostMapping("/logList")
    @ResponseBody
    public IPage<PsLogs> userList(@RequestParam(value = "currentPage" , required = false , defaultValue = "1")
                                          Integer currentPage,
                                  @RequestParam(value = "pageSize" , required = false , defaultValue = "10")
                                          Integer pageSize,
                                  @RequestParam(value = "start" ,required = false , defaultValue = "")
                                          String start,
                                  @RequestParam(value = "end" ,required = false , defaultValue = "")
                                          String end,
                                  @RequestParam(value = "userCode" , required = false)
                                            String userCode){
        return psLogsService.selectPageByEditions(currentPage,pageSize,start,end,userCode);
    }
}
